<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" language="java"
	import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<html>
	<head>
		<base href="<%=basePath%>"></base>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<!-- Libraries -->
		<link type="text/css" href="<%=path%>/manage/css/layout.css"
			rel="stylesheet" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/manage/css/jquery-ui-1.8.11.custom.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/manage/css/Tooltip.css" />
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-1.4.4.min.js"></script>

		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<%-- 验证js Start --%>
		<script type="text/javascript" src="<%=path%>/manage/js/Tooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.methods.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.defaults.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/errorTip.js"></script>

		<script type="text/javascript">
	$(document).ready(function() {
		var parkinginfoForm = $("#registeFrom").validate({

			rules : {
				"produceUserInfo.varLoginName" : {
					required : true
				},
				"produceUserInfo.varPassword" : {
					required : true
				},
				"mPassword" : {
					required : true,
					minlength : 5
				},
				"pPassword" : {
					required : true,
					minlength : 5
				},
				"produceUserInfo.intEnterpId" : {
					required : true

				},
				"manageUserInfo.varLoginName" : {
					required : true
				},

				"manageUserInfo.varPassword" : {
					required : true,
					minlength : 5,
					equalTo : "#mPassword"
				},
				"produceUserInfo.varPassword" : {
					required : true,
					minlength : 5,
					equalTo : "#pPassword"
				},
				"manageUserInfo.varEmail" : {
					email : true
				},
				"intTypeId" : {
					required : true
				}

			},
			messages : {
				"produceUserInfo.varLoginName" : {
					required : "请输入账号名称"

				},
				"produceUserInfo.varPassword" : {
					required : "请填写密码"
				},
				"produceUserInfo.intEnterpId" : {
					required : "请选所属企业"

				},
				"pPassword" : {
					required : "请输入密码",
					minlength : "确认密码不能小于5个字符"

				},
				"mPassword" : {
					required : "请输入密码",
					minlength : "确认密码不能小于5个字符"

				},
				"manageUserInfo.varLoginName" : {
					required : "请输入账号名称"
				},

				"manageUserInfo.varPassword" : {
					required : "请填写确认密码",
					equalTo : "两次输入密码不一致不一致",
					minlength : "确认密码不能小于5个字符"
				},
				"produceUserInfo.varPassword" : {
					required : "请填写确认密码",
					equalTo : "两次输入密码不一致不一致",
					minlength : "确认密码不能小于5个字符"
				},
				"manageUserInfo.varEmail" : {
					email : "请输入正确的邮箱格式"
				},
				"intTypeId" : {
					required : "请选择行业类型"
				}

			}
		});

	});

	function next() {
		document.getElementById('produce').style.display = 'none';
		document.getElementById('manage').style.display = '';
	}
	//check
	function checkName(obj) {
	    //alert($("#varLoginName").val());
		if (obj.value == "") {
			$(obj).addErrorMessage("请输入用户名");
		} else if (obj.value == $("#varLoginName").val()) {
			$(obj).addErrorMessage("对不起，用户名已经存在，请重新输入！谢谢。");
		} else {
			checkLoginName(obj);
		}

	}
	//check loginname
	function checkLoginName(obj) {
		if (obj.value == "") {
			$(obj).addErrorMessage("请输入用户名");
		} else {
			$.ajax({
				url : root + '/login/checkLoginName.action?username='
						+ encodeURI(encodeURI(obj.value)),
				method : 'post',
				dataType : 'json',
				success : function(data) {
					if (data.state == 0) {
						$(obj).addErrorMessage("对不起，用户名已经存在，请重新输入！谢谢。");
					} else {
						$(obj).removeErrorMessage();
					}
				},
				error : function() {
					alert("信息获取错误");
				}
			});
		}
	}

	//获取企业信息类表
	function getEntershop() {

		$.ajax({
			url : root + '/login/getEnterInfoList.action',
			method : 'post',
			dataType : 'json',
			data : {
				'intTypeId' : $("#intTypeId").val()
			},
			success : function(data) {
               $("#intEnterpId").empty(); 
               
				for (i = 0; i < data.length; i++) {
					//添加下拉框
					$(
							'<option value='+data[i].intEnterpId+'>'
									+ data[i].varEnterpName + '</option>')
							.appendTo('#intEnterpId');

				}

			},
			error : function() {
				alert("信息获取错误");
			}
		});
	}
</script>
	</head>

	<body>
		<!-- Background wrapper -->
		<div id="bgwrap">
			<!-- Main Content -->
			<div id="main">
				<p>
					当前位置：个人注册
				</p>
				<div class="pad20">
					<form action="<%=path%>/login/registeUser.action" method="post"
						id="registeFrom">
						<div id="manage" style="display: none;">
							<p>
								内容生成平台注册
							</p>
							<input type="hidden" name="manageUserInfo.varRoleType" value="1">
							<table class="fullwidth" cellpadding="0" cellspacing="0"
								border="0">
								<tr>
									<td>
										用户名
									</td>
									<td>
										<input type="text" name="manageUserInfo.varLoginName"
									onblur="checkName(this)">
										<span style="color: red">*</span>
										<span id="mnameMsg" style="display: none"></span>
									</td>
								</tr>
								<tr>
									<td>
										密码
									</td>
									<td>
										<input type="password" name="mPassword" id="mPassword">
										<span style="color: red">*</span>
									</td>
								</tr>

								<tr>
									<td>
										确认密码
									</td>
									<td>
										<input type="password" name="manageUserInfo.varPassword"
											id="varPassword">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										联系电话
									</td>
									<td>
										<input type="text" name="manageUserInfo.varPhonenum"
											id="varPhonenum">
									</td>
								</tr>
								<tr>
									<td>
										电子邮箱
									</td>
									<td>
										<input type="text" name="manageUserInfo.varEmail"
											id="varEmail">
									</td>
								</tr>
								<tr>
								
									<td>
									</td>
									<td>
										<input type="submit" value="注册">
										<input type="button" value="返回"
											onclick="document.getElementById('produce').style.display='';document.getElementById('manage').style.display='none';">
									</td>
								</tr>
							</table>
						</div>
						<div id="produce">
							<p>
								生成平台注册
							</p>
							<input type="hidden" name="produceUserInfo.varRoleType" value="0">
							<table class="fullwidth" cellpadding="0" cellspacing="0"
								border="0">
								<tr>
									<td>
										所属行业
									</td>
									<td>
										<s:select name="intTypeId" list="#request.typeEnterList"
											listKey="intTypeId" listValue="varTypeName" headerKey=""
											headerValue="—请选择—" onchange="getEntershop()" />
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										所属企业
									</td>
									<td>
										<select name="produceUserInfo.intEnterpId" id="intEnterpId">
											<option value="">
												-请选择-
											</option>
										</select>
										<span style="color: red">*</span>

									</td>
								</tr>
								<tr>
									<td>
										用户名
									</td>
									<td>
										<input type="text" name="produceUserInfo.varLoginName"
											onblur="checkLoginName(this)" id="varLoginName">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										密码
									</td>
									<td>
										<input type="password" name="pPassword" id="pPassword">
										<span style="color: red">*</span>
									</td>
								</tr>

								<tr>
									<td>
										确认密码
									</td>
									<td>
										<input type="password" name="produceUserInfo.varPassword"
											id="varPassword">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										联系电话
									</td>
									<td>
										<input type="text" name="produceUserInfo.varPhonenum"
											id="varPhonenum">
									</td>
								</tr>
								<tr>
									<td>
										电子邮箱
									</td>
									<td>
										<input type="text" name="produceUserInfo.varEmail"
											id="varEmail">
									</td>
								</tr>
								<tr>
									<td>
									</td>
									<td>
										<input type="button" value="下一步" onclick="next()">
									</td>
								</tr>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
	</body>
</html>
